import mockRequest from '@/utils/mockRequest'
import data from '../../../mock/data.json'
const state = {
  list: {}
}
const mutations = {
  GETDATA(state, list) {
    state.list = list
  }
}
const actions = {
  async getData({ commit }) {
    // 不用mock
    commit('GETDATA', data)

    // 使用mock获取数据
    const result = await mockRequest.get('/home/list')
    if (result.code == 20000) {
      commit('GETDATA', result.data)
    }
  }
}
export default {
  state,
  mutations,
  actions
}
